{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"-1\"\n",
    "import numpy as np\n",
    "\n",
    "from skimage import io\n",
    "from skimage import data\n",
    "from skimage.measure import block_reduce"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f803020b828>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAATgAAAEYCAYAAADI0+pcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJztnXusZWWZ5p/XAuQiUpRAUVIFxUVbVAaQCuAFFRwJONpiNF4zwUhC1J4E0520OJNM7GRi7Jhom8zEDmkdmKRtcWiZMsZpmgGNGm8UiNwLSqySgrqJoKCCoN/8cXbZ+/vtr/a71jmn9jmuPL+EcN691/rWu7619ld7Pfu9RClFxhgzRJ6z1A4YY8z+wgucMWaweIEzxgwWL3DGmMHiBc4YM1i8wBljBosXOGPMYPECZ4wZLAta4CLioojYHBFbIuLKxXLKGGMWg5hvJkNErJB0v6Q3Stou6RZJ7yml3LOvfQ4++OBy2GGHjY+RHWM+flU2z6/vmPPxYbnRusYLPa+FZsB0Of5yy7KZjz/ZPn3H7LJ932Nmn5n94eNC9nnqqaf0zDPPdLqBD+jtyb9xtqQtpZQHJSkiviTprZL2ucAddthhuvjii/9or1ixonqfE33AAbV73L61z3OeU38p/f3vfz/1/cyHbHxeGL7fou+i+4c//CEdc9r4XRa4vgse57Wvj7y2Lfp+ULJrTR8XOn5rzOx9HpNjPvvss73Gax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akXwuPo8vAR0mzXeAelrRuzF47em25sisi1kjS6P+7k+33KxFxoOYWt38spXxl9PKy8nEvpZTHJX1Dc497KyNib6XIpb7mr5b05xGxVdKXNPeY+lktLx9VSnl49P/dkq7X3D8Wy+lab5e0vZTyg5F9neYWvOXko6TZLnC3SHrR6BergyS9W9JXZ3j8vnxV0qWjvy/VnO61JMRcOdPPS7q3lPLpsbeWk49HR8TK0d+HaE4jvFdzC907RpstqY+llI+VUtaWUtZr7v67uZTyPi0jHyPisIg4fO/fki6UdJeW0bUupeyU9FBE/NnopTdIukfLyMc/MmNx8k2S7tecNvNfllqAHPPrnyTtkPSM5v51ukxz2sxNkh6Q9P8krVpC/16jua/7d0i6ffTfm5aZj/9O0o9GPt4l6b+OXj9J0g8lbZH0vyU9d6mv98iv10v62nLzceTLj0f/3b33c7KcrvXInzMkbRpd7/8j6cjl5mMpxalaxpjh4h8ZjDGDxQucMWaweIEzxgwWL3DGmMHiBc4YM1i8wBljBosXOGPMYPn/xDnkdYAd1rEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "image = io.imread('dog.jpg', as_gray=True)\n",
    "new_image = block_reduce(image, block_size=(5, 5), func=np.max)\n",
    "io.imshow(new_image)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
